<template>
  <div class="article-page">
    <!-- 轮播图区域 -->
    <van-swipe class="my-swipe" :autoplay="3000" indicator-color="white">
      <van-swipe-item
        ><img
          src="http://liufusong.top:8080/img/swiper/1.png"
          alt=""
          width="100%"
      /></van-swipe-item>
      <van-swipe-item
        ><img
          src="http://liufusong.top:8080/img/swiper/2.png"
          alt=""
          width="100%"
      /></van-swipe-item>
      <van-swipe-item
        ><img
          src="http://liufusong.top:8080/img/swiper/3.png"
          alt=""
          width="100%"
      /></van-swipe-item>
    </van-swipe>
    <!-- 搜索区域 -->
    <van-search v-model="value" placeholder="请输入小区或地址" show-action>
      <template #label>
        <span class="city" @click="$router.push('/city')">{{city.label}}</span>
        <span class="line"></span>
      </template>
      <template #action>
        <van-icon
          name="location-o"
          size="20"
          color="#fff"
         @click="$router.push('/map')"
        />
      </template>
    </van-search>

    <!-- 四宫格 -->
    <van-grid>
      <van-grid-item icon="wap-home-o" text="整租" />
      <van-grid-item icon="friends-o" text="合租" />
      <van-grid-item icon="map-marked" text="地图找房" to="/map" />
      <van-grid-item icon="wap-home" text="去出租" to="/rent" />
    </van-grid>
    <!-- 租房小组区域 -->
    <div class="zf">
      <div class="title">
        <span>租房小组</span>
        <a href="#">更多</a>
      </div>
      <div class="content">
        <van-grid direction="horizontal" :column-num="2" :gutter="10">
          <van-grid-item icon="photo-o" text="家住回龙观归属的感觉" />
          <van-grid-item icon="photo-o" text="宜居四五环大都市生活" />
          <van-grid-item icon="photo-o" text="喧嚣三里屯繁华的背后" />
          <van-grid-item icon="photo-o" text="比邻十号线地铁心连心" />
        </van-grid>
      </div>
    </div>
  </div>
</template>

<script>
import { getGroups } from '@/api/home'
export default {
  name: 'article-page',
  data () {
    return {
      value: '',
      city: JSON.parse(window.localStorage.getItem('city')) || {
        label: '上海',
        value: 'AREA|dbf46d32-7e76-1196',
        pinyin: 'shanghai',
        short: 'sh'
      }
    }
  },
  methods: {
    async created () {
      const res2 = await getGroups()
      console.log(res2)
      this.groups = res2.body
    }
  }
}
</script>

<style lang="less" scoped>
.my-swipe .van-swipe-item {
  color: #fff;
  font-size: 20px;
  line-height: 12px;
  text-align: center;
  background-color: #39a9ed;
}
.zf {
  background-color: #f6f5f6;
}
.zf .title {
  display: flex;
  height: 48px;
  line-height: 48px;
  justify-content: space-between;
}
.zf .title span {
  font-size: 15px;
  color: #333;
  font-weight: bold;
  padding-left: 10px;
}
.zf .title a {
  font-size: 14px;
  color: #787d82;
  padding-right: 5px;
}
/deep/ .van-grid-item {
  color: #21b97a;
}
.van-search__label {
  margin-right: 20px;
}
.line {
  width: 1px;
  height: 14px;
  background: #ccc;
  display: inline-block;
  margin-left: 20px;
  position: relative;
  top: 4px;
}
.van-search {
  position: fixed;
  top: 25px;
  width: 100%;
  background-color: transparent;
}
</style>
